package com.wzx.user.sdk.controller;

import com.wzx.common.exception.LeadNewsException;
import com.wzx.common.pojo.resp.Result;
import com.wzx.user.sdk.common.identity.spring.UserAuthForm;
import com.wzx.user.sdk.service.IdentityService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

/**
 * @author wzx
 * @version 1.0
 * @date 2022/10/31 - 11:36
 * @description 标题
 */
@RestController
@RequestMapping("/identity")
public class IdentityController {

    @Autowired
    private IdentityService identityService;

    @PostMapping("/authAccount")
    @ApiOperation(value = "用户的实名认证")
    public Result identifyCheck(@RequestBody UserAuthForm userAuthForm) throws Exception {
        String resultStr = identityService.identifyVerify(userAuthForm);
        return Result.ok(resultStr);
    }

    @GetMapping("/judgeCheck")
    @ApiOperation(value = "判断用户是否认证")
    public Result judgeCheck(Integer userId) throws LeadNewsException {
        boolean judge = identityService.judgeCheck(userId);
        return Result.ok(judge);
    }

    @GetMapping("/queryName")
    @ApiOperation(value = "查询实名认证姓名")
    public Result queryName(Integer userId) throws LeadNewsException {
        String name = identityService.queryName(userId);
        return Result.ok(name);
    }
}
